MODULE GLOBVAR
  !USE NRUTIL, ONLY : ARRAY1D
  IMPLICIT NONE
  
  INTEGER, PARAMETER :: N_ind=707    ! Number of individuals
  INTEGER, PARAMETER :: N_k=10       ! Number of individuals
  INTEGER, PARAMETER :: N_inds=N_ind*N_k   ! Number of simulated individuals
  INTEGER, PARAMETER :: N_test=349   ! Number of test in China REACH curriculum
  !INTEGER, PARAMETER :: N_var=4+2*N_testl   ! Number of parameters
  INTEGER, PARAMETER :: N_testt=195  ! Number of Total tasks for l c2 f2 and g 
  INTEGER, PARAMETER :: N_testl=110  ! Number of Language I task
  INTEGER, PARAMETER :: N_testc=70   ! Number of cognitive II task
  INTEGER, PARAMETER :: N_testf=30   ! Number of Fine Motor II task
  INTEGER, PARAMETER :: N_testg=22   ! Number of Gross Motor task
  INTEGER, PARAMETER :: N_levell=11  ! Number of Language I level
  INTEGER, PARAMETER :: N_levelc=13  ! Number of cognitive II level
  INTEGER, PARAMETER :: N_levelf=7   ! Number of Fine Motor II level
  INTEGER, PARAMETER :: N_levelg=9   ! Number of Gross Motor level
  INTEGER, PARAMETER :: N_x_l0=6     ! Number of initial latent skill 
  INTEGER, PARAMETER :: N_x_eta=6    ! Number of learning parameter 
  INTEGER, PARAMETER :: N_mom=25*(2*N_levell-5)+3*N_testt+N_levell+(N_levell-1)*10+n_levelc+n_levelf+177+84+82+43+142+79+5*n_levell+5*n_levelc +5*n_levelf  ! number of moments
  INTEGER, PARAMETER :: N_var=n_x_l0+3*N_levell+n_x_eta-4+n_x_l0+3*N_levelc+n_x_eta-6+n_x_l0+3*N_levelf+n_x_eta-2+6+9+9+3 ! number of parameters
  INTEGER, PARAMETER :: N_boot=200
  
  
  
  !INTEGER, PARAMETER :: N_int=1000     ! Number of estimation
  
  !INTEGER, PARAMETER :: N_test=5
  !INTEGER, PARAMETER :: N_mom=N_testl*(3*N_test-3)+2*(N_testl-1)*N_test+N_testl*(2*N_test-3)
  INTEGER :: N_type !N_test, N_test_o,n_order,
  !INTEGER,ALLOCATABLE:: N_cut(:)

  !Task 
  INTEGER :: l_test(N_ind,N_testt),c_test(N_ind, N_testt),f_test(N_ind, N_testt),g_test(N_ind,N_testt),m_l(N_ind,N_testt),m_c(N_ind,N_testt),m_f(N_ind,N_testt),m_g(N_ind,N_testt)
  INTEGER :: levell(N_testt),levelc(N_testt),levelf(N_testt),levelg(N_testt),indl(N_ind,N_testt),indc(N_ind,N_testt),indf(N_ind,N_testt),indg(N_ind,N_testt),&
  repl(N_ind,N_testt),repc(N_ind,N_testt),repf(N_ind,N_testt),repg(N_ind,N_testt),repeatl(N_testt),repeatc(N_testt),repeatf(N_testt),repeatg(N_testt),&
  month(N_testt), time(N_testt),t_test(N_ind,N_testt),m_t(N_ind,N_testt)    
  REAL(8) :: x_testl(N_ind,N_testt,6),x_testc(N_ind,N_testt,6),x_testf(N_ind,N_testt,6),x_testg(N_ind,N_testt,6),L0(N_ind,6),firstl(N_ind,2),firstc(N_ind,2),&
  firstf(N_ind,2),firstg(N_ind,2),x_testt(N_ind,N_testt,6),firstt(N_ind,2)
  REAL(8) :: moment(N_mom),momentboot(n_boot,n_mom),thetaboot(n_boot,n_var),thetafix(n_x_l0+3*N_levelf+n_x_eta-2),intermean(N_ind)
  INTEGER :: countnum(N_mom),mmboot(n_boot,n_ind),mmb(n_ind),id(n_ind)   
  INTEGER :: dul_l(n_ind,n_levell),duc_c(n_ind,n_levelc),duf_f(n_ind,n_levelf)
  REAL(8) :: ave_l(n_ind,n_levell),ave_c(n_ind,n_levelc),ave_f(n_ind,n_levelf)

  ! Variables for MPI
  INTEGER :: myid,numprocs
  
    ! Variance adjustment
  !REAL(8),ALLOCATABLE  :: sigma(:,:)
  
  
  

  
      
  

  
 
  
END MODULE GLOBVAR
